package com.guan.mymap;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.widget.SimpleExpandableListAdapter;

public class GroupListView extends ExpandableListActivity {
	/** Called when the activity is first created. */  
	   
    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.grouplist);  
          
        List<Map<String,String>> groups = new ArrayList<Map<String,String>>();  
        Map<String,String> group1 = new HashMap<String,String>();  
        group1.put("group", "group1");
        Map<String,String> group2 = new HashMap<String,String>();  
        group2.put("group", "group2");
        groups.add(group1);  
        groups.add(group2);  
          
        List<Map<String,String>> child1 = new ArrayList<Map<String,String>>();  
        Map<String,String> child1data1 = new HashMap<String,String>();  
        child1data1.put("child", "child1data1");  
        child1.add(child1data1);  
        Map<String,String> child1data2 = new HashMap<String,String>();  
        child1data2.put("child", "child1data2");  
        child1.add(child1data2);  
          
        List<Map<String,String>> child2 = new ArrayList<Map<String,String>>();  
        Map<String,String> child2data1 = new HashMap<String,String>();  
        child2data1.put("child", "child2data1");  
        child2.add(child2data1);  
          
        List<List<Map<String,String>>> childs = new ArrayList<List<Map<String,String>>>();  
        childs.add(child1);  
        childs.add(child2);  
        SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(this,  
                groups, R.layout.group,new String[] {"group"},  
                new int[] {R.id.groupTo}, childs, R.layout.child, new String[] {"child"}, new int[] {R.id.childTo});  
        setListAdapter(adapter);  
    }  
}
